﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LAVAA.DAL;

namespace LAVAA.BL.Business
{
    public class UserGroupManager
    {       
        private UnitOfWork _uow;

        public UserGroupManager(UnitOfWork uow)
        {
            this._uow = uow;
        }

        public void AddUserGroup(UserGroup userGroup)
        {
            if (_uow.UserGroupRepository.Find(filter: c => c.Name == userGroup.Name).Count() > 0)
                throw new Exception("Another usergroup with the same name already exists");
            _uow.UserGroupRepository.Add(userGroup);
        }

        public void UpdateUserGroup(UserGroup userGroup)
        {
            _uow.UserGroupRepository.Update(userGroup);
        }

        public void DeleteUserGroup(Guid id)
        {
            _uow.UserGroupRepository.Delete(id);
        }

    }
}
